home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / WizardModelSubDbQueryJoin.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  4.1 KB  |  100 lines

  1. package asp.wizard;
  2.  
  3. import asp.netobjects.nfx.ui.OrderedListModel;
  4. import asp.netobjects.nfx.util.ExceptionHandler;
  5. import asp.netobjects.nfx.util.ExternalError;
  6. import asp.netobjects.nfx.util.InternalError;
  7. import asp.netobjects.nfx.wizard.Wizard;
  8. import asp.netobjects.nfx.wizard.WizardPage;
  9. import asp.netobjects.nfx.wizard.WizardPageView;
  10. import asp.wizard.def.DefConnection;
  11. import com.sun.java.swing.ImageIcon;
  12. import java.util.Vector;
  13.  
  14. public class WizardModelSubDbQueryJoin extends WizardModelSub {
  15.    private SubDBQueryData _Data;
  16.    private WizardSubDbQuery _Wizard;
  17.  
  18.    public WizardModelSubDbQueryJoin() {
  19.       super.dmCanFinish = true;
  20.    }
  21.  
  22.    public WizardModelSubDbQueryJoin(Wizard wizard, String bullet, String info, ImageIcon icon, ExceptionHandler handler) {
  23.       super(wizard, bullet, info, icon, handler);
  24.       super.dmCanFinish = true;
  25.       this._Wizard = (WizardSubDbQuery)wizard;
  26.       this._Data = this._Wizard.getData();
  27.    }
  28.  
  29.    public SubDBQueryData getData() {
  30.       return this._Data;
  31.    }
  32.  
  33.    protected WizardPageView getViewSingleInstance() {
  34.       WizardViewSubDbQueryJoin wizard = (WizardViewSubDbQueryJoin)WizardViewSubDbQueryJoin.getInstance();
  35.       return WizardViewSubDbQueryJoin.getInstance();
  36.    }
  37.  
  38.    public WizardPage createNext() {
  39.       return new WizardModelSubDbQueryWhere(this._Wizard, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
  40.    }
  41.  
  42.    public void validate() throws InternalError, ExternalError {
  43.       super.validate();
  44.       WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)this.getViewSingleInstance();
  45.  
  46.       try {
  47.          this._Data.getFrom(view.getJoins());
  48.       } catch (Exception e) {
  49.          throw new ExternalError(((Throwable)e).getMessage());
  50.       }
  51.    }
  52.  
  53.    public void updateTableComboBox() {
  54.       WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)((WizardPage)this).getView();
  55.       OrderedListModel tables = this._Data.getSelectedTables();
  56.       view.setLhsTableComboBoxModel(tables);
  57.       view.setRhsTableComboBoxModel(tables);
  58.    }
  59.  
  60.    public void updateLhsFieldList() {
  61.       WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)((WizardPage)this).getView();
  62.       OrderedListModel olmFields = new OrderedListModel();
  63.       String selTableName = view.getLhsSelectedTable();
  64.       if (selTableName != null && !selTableName.equals("")) {
  65.          DefConnection dc = ((WizardSubDbQuery)((WizardPage)this).getWizard()).getDefConnection();
  66.          SubDBQueryData.setFields(dc, olmFields, selTableName, (boolean[])null);
  67.          olmFields.setOrdered(true);
  68.       }
  69.  
  70.       view.setLhsFieldListModel(olmFields);
  71.    }
  72.  
  73.    public void updateRhsFieldList() {
  74.       WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)((WizardPage)this).getView();
  75.       OrderedListModel olmFields = new OrderedListModel();
  76.       String selTableName = view.getRhsSelectedTable();
  77.       if (selTableName != null && !selTableName.equals("")) {
  78.          DefConnection dc = ((WizardSubDbQuery)((WizardPage)this).getWizard()).getDefConnection();
  79.          SubDBQueryData.setFields(dc, olmFields, selTableName, (boolean[])null);
  80.          olmFields.setOrdered(true);
  81.       }
  82.  
  83.       view.setRhsFieldListModel(olmFields);
  84.    }
  85.  
  86.    public void loadView() {
  87.       this.updateTableComboBox();
  88.       this.updateLhsFieldList();
  89.       this.updateRhsFieldList();
  90.       this._Data.removeUnsupportedJoins();
  91.       Vector joins = this._Data.getJoins();
  92.       ((WizardViewSubDbQueryJoin)((WizardPage)this).getView()).setJoins(joins);
  93.    }
  94.  
  95.    public void commit() throws InternalError, ExternalError {
  96.       WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)this.getViewSingleInstance();
  97.       this._Data.setJoins(view.getJoins());
  98.    }
  99. }
  100.